using GraphQLDemo.Domain;
using GraphQLDemo.Domain.Contracts;

namespace GraphQLDemo.Infrastructure.Repositories
{
    public class ContractRepository : IContractRepository
    {
        public Task<IDictionary<Guid, int>> GetItemsCountByIdAsync(IEnumerable<Guid> contractIds, CancellationToken cancellationToken)
        {
            var itemsCounts = new Dictionary<Guid, int>()
            {
                { contractIds.First(), 5  },
                { contractIds.Last(), 5  }
            };
            return Task.FromResult((IDictionary<Guid, int>)itemsCounts);
        }

        public Task<List<Contract>> GetListAsync()
        {
            Console.WriteLine("Execute ContractRepository-GetListAsync");

            var contracts = new List<Contract>()
            {
                new Contract()
                {
                    Id = Guid.Parse("57CFDDA8-81A6-4758-ABEF-4C69CA340098"),
                    Name = "contract1",
                    ContractItems = new List<ContractItem>()
                    {
                        new ContractItem()
                        {
                            Id = Guid.NewGuid(),
                            ContractId = Guid.Parse("57CFDDA8-81A6-4758-ABEF-4C69CA340098"),
                            Content = "content"
                        }
                    }
                },
                new Contract()
                {
                    Id = Guid.Parse("57CFDDA8-81A6-4758-ABEF-4C69CA340099"),
                    Name = "contract2",
                    ContractItems = new List<ContractItem>()
                    {
                        new ContractItem()
                        {
                            Id = Guid.NewGuid(),
                            ContractId = Guid.Parse("57CFDDA8-81A6-4758-ABEF-4C69CA340099"),
                            Content = "content"
                        }
                    }
                }
            };

            return Task.FromResult(contracts);
        }
    }
}